<%@ page language="java" contentType="text/html; charset=UTF-8"
import="it.polimi.swim.entity.SystemUser,java.util.List,it.polimi.swim.entity.Feedback"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="myStyle.css">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<div id='header' name = "header">
	<a href="<%
	if (session.getAttribute("id")==null) out.print("index.jsp");
	else out.print("homeUser.jsp");%>">SWIMv2</a>
</div>
<div id="content">
	<div id="users"><%
SystemUser user = (SystemUser)request.getAttribute("currUser");
List<SystemUser> users = (List<SystemUser>)request.getAttribute("friendList");
List<List<Feedback>> feeds = (List<List<Feedback>>) request.getAttribute("feedList");
System.out.print(feeds.size());
if(users.size()>0){
	int i=0; %>
	<br><br><table cellpadding="5" class="userInformations">
	<%
	for(SystemUser u: users){ 
		if(session.getAttribute("id")==null || (Integer)session.getAttribute("id")!=u.getId()){%>
		<tr><td><div class="listUser">
				<div class="leftCell"><img src="img/user.jpg" width="60"/></div>
				<div class="rightCell">
				<form class="userData" action="SendFriendRequestServlet?idUser=<%out.print(u.getId()); %>" method="post">
					<%
					out.println("Name: "+u.getName()+"<br>");
					out.println("Surname: "+u.getSurname()+"<br>");
					out.println("City: "+u.getCity()+"<br>");
					if(feeds.get(i).size()>0){%>
					<div class="listFeed">
					<table>
					<% 
						for(Feedback feed:feeds.get(i)){%>
						<tr><td width="28"><img src="<%
						if(feed.getEvaluation()) out.print("img/pollicesu.png");
						else if(!feed.getEvaluation()) out.print("img/polliceverso.png");%>" height="20">
						</td>
						<td>
						<%
							out.print(feed.getText()+"</td></tr>");
						}
					%>
					</table></div>
					<% i++;
					}
					if (session.getAttribute("id")!=null){
						%>
						<input type=submit value="Send Friend Request"><br><br>
						<%	
					}%>
				</form></div></div></td></tr>
			<%
			}		
		}%>
</table>
<%}else{
			out.println("User not exist<br>");
}
	%>
	</div>
</div>
</body>
</html>